package com.topwater.topwater.service.impl;

import com.topwater.topwater.entity.IvInvoice;
import com.topwater.topwater.dao.IvInvoiceDao;
import com.topwater.topwater.service.IvInvoiceService;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Param;

import javax.annotation.Resource;

/**
 * (IvInvoice)表服务实现类
 *
 * @author 胡文 qq:986776
 * 自定义生成器制造
 */
@Service("ivInvoiceService")
public class IvInvoiceServiceImpl implements IvInvoiceService {
    @Resource
    private IvInvoiceDao ivInvoiceDao;

    /**
     * 通过ID查询单条数据
     *
     * @param invoiceno 主键
     * @return 实例对象
     */
    @Override
    public IvInvoice queryById(String invoiceno) {
        return this.ivInvoiceDao.queryById(invoiceno);
    }


    /**
     * 新增数据
     *
     * @param ivInvoice 实例对象
     * @return 实例对象
     */
    @Override
    public IvInvoice insert(IvInvoice ivInvoice) {
        this.ivInvoiceDao.insert(ivInvoice);
        return ivInvoice;
    }

    @Override
    public IvInvoice insertNotNull(IvInvoice ivInvoice) {
        this.ivInvoiceDao.insertNotNull(ivInvoice);
        return ivInvoice;
    }

    /**
     * 修改数据
     *
     * @param ivInvoice 实例对象
     * @return 实例对象
     */
    @Override
    public IvInvoice update(IvInvoice ivInvoice) {
        this.ivInvoiceDao.update(ivInvoice);
        return this.queryById(ivInvoice.getInvoiceno());
    }

    /**
     * 通过主键删除数据
     *
     * @param invoiceno 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(String invoiceno) {
        return this.ivInvoiceDao.deleteById(invoiceno) > 0;
    }

    /**
     * 字符串自动模糊查询
     **/
    public List<IvInvoice> queryByLike(IvInvoice ivInvoice) {
        return this.ivInvoiceDao.queryByLike(ivInvoice);
    }

    public List<IvInvoice> queryByLike2(String str) {
        return this.ivInvoiceDao.queryByLike2(str);
    }

    /**
     * 多表连接查询
     */
    public List<Map> queryJoin(@Param("ivInvoice") IvInvoice ivInvoice, @Param("tables") String... tables) {
        return this.ivInvoiceDao.queryJoin(ivInvoice, tables);
    }
}
